Fix some issues with RepoFile
authorFelix Krull <f_krull@gmx.de>
Sat, 18 May 2019 15:18:11 +0000 (17:18 +0200)
committerColin Walters <walters@verbum.org>
Fri, 6 May 2022 16:53:53 +0000 (12:53 -0400)
rust-bindings/rust/conf/ostree.toml
rust-bindings/rust/gir-files/OSTree-1.0.gir
rust-bindings/rust/src/auto/repo_file.rs

index ca6a558202cdfc6a3f0776a96b74b93e4096c2e8..b7c0347b9b378db7722d7844e919dbe56e8ea078 100644 (file)
@@ -22,6 +22,7 @@ generate = [
     "OSTree.RepoCommitModifier",
     "OSTree.RepoCommitState",
     "OSTree.RepoDevInoCache",
+    "OSTree.RepoFile",
     "OSTree.RepoListRefsExtFlags",
     "OSTree.RepoMode",
     "OSTree.RepoPruneFlags",
@@ -78,21 +79,6 @@ status = "generate"
     pattern = ".+_async"
     ignore = true
 
-[[object]]
-name = "OSTree.RepoFile"
-status = "generate"
-    [[object.function]]
-    pattern = "get_xattrs"
-    ignore = true
-
-    [[object.function]]
-    pattern = "tree_find_child"
-    ignore = true
-
-    [[object.function]]
-    pattern = "tree_query_child"
-    ignore = true
-
 [[object]]
 name = "OSTree.*"
 status = "generate"
index 53f62efedede9ae4853d43f3bf05e6af55155f34..2ef6668675a4e858c2026210efa684906b3c316b 100644 (file)
@@ -8049,15 +8049,23 @@ options.  This is used by ostree_repo_export_tree_to_archive().</doc>
         </return-value>
         <parameters>
           <instance-parameter name="self" transfer-ownership="none">
+            <doc xml:space="preserve">#OstreeRepoFile</doc>
             <type name="RepoFile" c:type="OstreeRepoFile*"/>
           </instance-parameter>
-          <parameter name="out_xattrs" transfer-ownership="none">
+          <parameter name="out_xattrs"
+                     direction="out"
+                     caller-allocates="0"
+                     transfer-ownership="full"
+                     optional="1"
+                     allow-none="1">
+            <doc xml:space="preserve">the extended attributes</doc>
             <type name="GLib.Variant" c:type="GVariant**"/>
           </parameter>
           <parameter name="cancellable"
                      transfer-ownership="none"
                      nullable="1"
                      allow-none="1">
+            <doc xml:space="preserve">Cancellable</doc>
             <type name="Gio.Cancellable" c:type="GCancellable*"/>
           </parameter>
         </parameters>
@@ -8069,15 +8077,23 @@ options.  This is used by ostree_repo_export_tree_to_archive().</doc>
         </return-value>
         <parameters>
           <instance-parameter name="self" transfer-ownership="none">
+            <doc xml:space="preserve">#OstreeRepoFile</doc>
             <type name="RepoFile" c:type="OstreeRepoFile*"/>
           </instance-parameter>
           <parameter name="name" transfer-ownership="none">
+            <doc xml:space="preserve">name of the child</doc>
             <type name="utf8" c:type="const char*"/>
           </parameter>
-          <parameter name="is_dir" transfer-ownership="none">
+          <parameter name="is_dir"
+                     direction="out"
+                     caller-allocates="1"
+                     transfer-ownership="none">
             <type name="gboolean" c:type="gboolean*"/>
           </parameter>
-          <parameter name="out_container" transfer-ownership="none">
+          <parameter name="out_container"
+                     direction="out"
+                     caller-allocates="0"
+                     transfer-ownership="full">
             <type name="GLib.Variant" c:type="GVariant**"/>
           </parameter>
         </parameters>
@@ -8134,6 +8150,7 @@ options.  This is used by ostree_repo_export_tree_to_archive().</doc>
         </return-value>
         <parameters>
           <instance-parameter name="self" transfer-ownership="none">
+            <doc xml:space="preserve">#OstreeRepoFile</doc>
             <type name="RepoFile" c:type="OstreeRepoFile*"/>
           </instance-parameter>
           <parameter name="n" transfer-ownership="none">
@@ -8145,13 +8162,17 @@ options.  This is used by ostree_repo_export_tree_to_archive().</doc>
           <parameter name="flags" transfer-ownership="none">
             <type name="Gio.FileQueryInfoFlags" c:type="GFileQueryInfoFlags"/>
           </parameter>
-          <parameter name="out_info" transfer-ownership="none">
+          <parameter name="out_info"
+                     direction="out"
+                     caller-allocates="0"
+                     transfer-ownership="full">
             <type name="Gio.FileInfo" c:type="GFileInfo**"/>
           </parameter>
           <parameter name="cancellable"
                      transfer-ownership="none"
                      nullable="1"
                      allow-none="1">
+            <doc xml:space="preserve">Cancellable</doc>
             <type name="Gio.Cancellable" c:type="GCancellable*"/>
           </parameter>
         </parameters>
index bdfc97963be2429a774d522ecda8e04183c3867b..500023feb201a2c00e5fc156e9f1cde207a30e05 100644 (file)
@@ -34,6 +34,10 @@ pub trait RepoFileExt {
 
     fn get_root(&self) -> Option<RepoFile>;
 
+    fn get_xattrs<'a, P: Into<Option<&'a gio::Cancellable>>>(&self, cancellable: P) -> Result<glib::Variant, Error>;
+
+    fn tree_find_child(&self, name: &str) -> (i32, bool, glib::Variant);
+
     fn tree_get_contents(&self) -> Option<glib::Variant>;
 
     fn tree_get_contents_checksum(&self) -> Option<String>;
@@ -42,6 +46,8 @@ pub trait RepoFileExt {
 
     fn tree_get_metadata_checksum(&self) -> Option<String>;
 
+    fn tree_query_child<'a, P: Into<Option<&'a gio::Cancellable>>>(&self, n: i32, attributes: &str, flags: gio::FileQueryInfoFlags, cancellable: P) -> Result<gio::FileInfo, Error>;
+
     fn tree_set_metadata(&self, checksum: &str, metadata: &glib::Variant);
 }
 
@@ -72,6 +78,26 @@ impl<O: IsA<RepoFile>> RepoFileExt for O {
         }
     }
 
+    fn get_xattrs<'a, P: Into<Option<&'a gio::Cancellable>>>(&self, cancellable: P) -> Result<glib::Variant, Error> {
+        let cancellable = cancellable.into();
+        let cancellable = cancellable.to_glib_none();
+        unsafe {
+            let mut out_xattrs = ptr::null_mut();
+            let mut error = ptr::null_mut();
+            let _ = ffi::ostree_repo_file_get_xattrs(self.to_glib_none().0, &mut out_xattrs, cancellable.0, &mut error);
+            if error.is_null() { Ok(from_glib_full(out_xattrs)) } else { Err(from_glib_full(error)) }
+        }
+    }
+
+    fn tree_find_child(&self, name: &str) -> (i32, bool, glib::Variant) {
+        unsafe {
+            let mut is_dir = mem::uninitialized();
+            let mut out_container = ptr::null_mut();
+            let ret = ffi::ostree_repo_file_tree_find_child(self.to_glib_none().0, name.to_glib_none().0, &mut is_dir, &mut out_container);
+            (ret, from_glib(is_dir), from_glib_full(out_container))
+        }
+    }
+
     fn tree_get_contents(&self) -> Option<glib::Variant> {
         unsafe {
             from_glib_full(ffi::ostree_repo_file_tree_get_contents(self.to_glib_none().0))
@@ -96,6 +122,17 @@ impl<O: IsA<RepoFile>> RepoFileExt for O {
         }
     }
 
+    fn tree_query_child<'a, P: Into<Option<&'a gio::Cancellable>>>(&self, n: i32, attributes: &str, flags: gio::FileQueryInfoFlags, cancellable: P) -> Result<gio::FileInfo, Error> {
+        let cancellable = cancellable.into();
+        let cancellable = cancellable.to_glib_none();
+        unsafe {
+            let mut out_info = ptr::null_mut();
+            let mut error = ptr::null_mut();
+            let _ = ffi::ostree_repo_file_tree_query_child(self.to_glib_none().0, n, attributes.to_glib_none().0, flags.to_glib(), &mut out_info, cancellable.0, &mut error);
+            if error.is_null() { Ok(from_glib_full(out_info)) } else { Err(from_glib_full(error)) }
+        }
+    }
+
     fn tree_set_metadata(&self, checksum: &str, metadata: &glib::Variant) {
         unsafe {
             ffi::ostree_repo_file_tree_set_metadata(self.to_glib_none().0, checksum.to_glib_none().0, metadata.to_glib_none().0);